﻿
@{
    ViewBag.Title = "添加商品";
}
@model RXY_Mall.Application.Shop.Dto.ShopCategoryDto
@section CSS{
    <link href="~/Content/css/layerui/layui.css" rel="stylesheet" />
    <link href="~/Content/js/UploadImg/css/webuploader.css" rel="stylesheet" />
    <link href="~/Content/js/UploadImg/css/goodsupload.css" rel="stylesheet" />
}
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            添加
            <small>商品</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">商家管理</a></li>
            <li><a href="/shop/company">店铺列表</a></li>
            <li class="active">添加商品</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                        <div class="ibox float-e-margins">
                            <div class="ibox-content ">
                                <form class="form-horizontal" id="form-add" method="post" action="/goods/AddorEditGoodsInfo">
                                    @if (null != Model && Model.Id > 0)
                                    {
                                        <input type="hidden" id="shop_id" name="shop_id" value="@Model.ShopId" />
                                        <input type="hidden" id="type_id" name="type_id" value="@Model.TypeId" />
                                        <input type="hidden" id="category_id" name="category_id" value="@(Model.CategoryTwoId>0?Model.CategoryTwoId:Model.CategoryOneId)" />
                                        <input type="hidden" id="category_id1" name="category_id1" value="@Model.CategoryOneId" />
                                        <input type="hidden" id="category_id2" name="category_id2" value="@Model.CategoryTwoId" />
                                        <input type="hidden" id="freight_template_id" name="freight_template_id" value="-1" />
                                        <input type="hidden" id="freight_chargetype" name="freight_chargetype" value="" />
                                        <div class="col-md-12">
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">商品名称 <span style="color:red;">*</span>：</label>
                                                <div class="col-sm-10">
                                                    <input type="text" name="name" id="name" maxlength="40" class="form-control" placeholder="请输入商品名称" required="" aria-required="true">
                                                    <span class="help-block m-b-none">不超过40个字；命名规则：品牌+名称+规格(颜色、尺码、重量、型号等)</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">短标题 <span style="color:red;">*</span>：</label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="short_title" id="short_title" maxlength="20" class="form-control" placeholder="请输入短标题" required="" aria-required="true">
                                                </div>
                                                <span class="help-block m-b-none">不超过20个字</span>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">品牌 <span style="color:red;">*</span>：</label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="brand" id="brand" maxlength="20" required="" class="form-control" placeholder="请输入商品品牌">
                                                </div>
                                                <span class="help-block m-b-none">不超过20个字</span>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">商品卖点：</label>
                                                <div class="col-sm-10">
                                                    <input type="text" name="summary" id="summary" maxlength="250" class="form-control" placeholder="请输入商品卖点">
                                                    <span class="help-block m-b-none">最多不超过250个字</span>
                                                </div>
                                            </div>

                                            @if (Model.TypeId == 2 || Model.TypeId == 4)
                                            {
                                                <div class="form-group" style="display:none">
                                                    <label class="col-sm-2 control-label">平台价(元)<span style="color:red;">*</span>：</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" class="form-control" value="@(Model.TypeId == 4? "1" : "0" )" placeholder="请输入销售价" disabled="disabled">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">平台价(元)<span style="color:red;">*</span>：</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="sale_price" id="sale_price" class="form-control" placeholder="请输入销售价" required="" aria-required="true" number="true">

                                                    </div>
                                                    @*<span class="help-block m-b-none">后期预留，拷贝为普通商品、趣卡商品时，作为平台价</span>*@
                                                </div>
                                            }
                                            else
                                            {
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">平台价(元)<span style="color:red;">*</span>：</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="sale_price" id="sale_price" class="form-control" placeholder="请输入平台价" required="" aria-required="true" number="true">
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                </div>
                                            }
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">市场价(元)<span style="color:red;">*</span>：</label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="market_price" id="market_price" class="form-control" placeholder="请输入市场价格" required="" aria-required="true" number="true">
                                                    <span class="help-block m-b-none"></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">结算价(元)<span style="color:red;">*</span>：</label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="settlement_price" id="settlement_price" class="form-control" placeholder="请输入结算价" required="" aria-required="true" number="true">

                                                </div>
                                                <span class="help-block m-b-none" style="display:@(Model.TypeId == 1?"":"none")">下期更改预留，目前采用服务费率结算方式；其他类型商品当前使用</span>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">商品重量(g) ：</label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="weight" id="weight" class="form-control" placeholder="请输入商品重量">
                                                    <span class="help-block m-b-none"></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">运费模板<span style="color:red;">*</span>：</label>
                                                <div class="col-sm-3">
                                                    <select style="width: 150px; height: 35px;" id="freight_template"></select>
                                                </div>
                                            </div>
                                            <div class="form-group" style="display:none">
                                                <label class="col-sm-2 control-label">订单最大可买数量：</label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="limit_quantity" id="limit_quantity" class="form-control" placeholder="" required="" value="999" aria-required="true" number="true">
                                                    <span class="help-block m-b-none"></span>
                                                </div>
                                                <label class="col-sm-2 control-label">通知管理员数量：</label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="notify_admin_quantity" id="notify_admin_quantity" class="form-control" placeholder="" value="10" required="" aria-required="true" number="true">
                                                    <span class="help-block m-b-none"></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">排序：</label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="sort" id="sort" number="true" aria-required="false" class="form-control" value="99" placeholder="请输入排序数">
                                                </div>
                                            </div>
                                            <div class="form-group" style="display:none">
                                                <label class="col-sm-1 control-label"></label>
                                                <div class="col-sm-3">
                                                    <label class="control-label"><input type="checkbox" name="is_new" id="is_new" value="true" checked="checked" class="i-checks">是否新品</label> &nbsp;&nbsp;
                                                    <label class="control-label"><input type="checkbox" name="is_top" id="is_top" value="false" class="i-checks">是否置顶</label> &nbsp;&nbsp;
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <input type="hidden" name="goods_service" id="goods_service" value="">
                                                <input type="hidden" name="goods_service_list" id="goods_service_list" value="">
                                                <label class="col-sm-2 control-label">商品服务：</label>
                                                <div class="col-sm-10" id="services">

                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">商品图片：</label>
                                                <div class="col-sm-10">
                                                    <div id="uploader0" class="goodsuploader">
                                                        <div class="item_container">
                                                            <div class="queueList" id="queueList0">
                                                                <div id="dndArea0" class="placeholder">
                                                                    <div id="filePicker01" style="line-height:12px;"></div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="statusBar" id="statusBar0" style="display:none;">
                                                            <div class="progress" id="progress0">
                                                                <span class="text">0%</span>
                                                                <span class="percentage"></span>
                                                            </div><div class="info" id="info0"></div>
                                                            <div class="btns">
                                                                <div id="filePicker02"></div><div class="uploadBtn" id="uploadBtn0">开始上传</div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <span class="help-block m-b-none">最多可上传 6 张图片，每张大小不超过 1 M</span>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">商品描述：</label>
                                                <div class="col-sm-10">
                                                    <textarea name="description" id="description" maxlength="500" class="form-control" placeholder="请输入商品描述" rows="3" value=""></textarea>
                                                    <span class="help-block m-b-none"></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">内容图片：</label>
                                                <div class="col-sm-10">
                                                    <div id="uploader1" class="goodsuploader">
                                                        <div class="item_container">
                                                            <div class="queueList" id="queueList1">
                                                                <div id="dndArea1" class="placeholder">
                                                                    <div id="filePicker11" style="line-height:12px;"></div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="statusBar" id="statusBar1" style="display:none;">
                                                            <div class="progress" id="progress1">
                                                                <span class="text">0%</span>
                                                                <span class="percentage"></span>
                                                            </div><div class="info" id="info1"></div>
                                                            <div class="btns">
                                                                <div id="filePicker12"></div><div class="uploadBtn" id="uploadBtn1">开始上传</div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <span class="help-block m-b-none">最多可上传 30 张图片，每张大小不超过 1 M</span>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>
                                            @if (Model.TypeId == 1)
                                            {
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">服务费率(％)：</label>
                                                    <div class="col-sm-1">
                                                        <input type="text" name="service_rate" id="service_rate" digits="true" class="form-control" placeholder="请输入服务费率" required="" value="" aria-required="true" number="true">
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                    <label class="col-sm-2 control-label">红包比例%：</label>
                                                    <div class="col-sm-1">
                                                        <input type="text" name="red_packet" id="red_packet" value="80" digits="true" aria-required="false" class="form-control" placeholder="请输入红包比例">
                                                    </div>
                                                    @*</div>
                <div class="form-group">*@
                                                    <label class="col-sm-2 control-label">拼团人数：</label>
                                                    <div class="col-sm-1">
                                                        <input type="text" name="require_num" id="require_num" number="true" value="3" aria-required="false" class="form-control" placeholder="请输入人数">
                                                    </div>
                                                    <label class="col-sm-2 control-label">拼团时长(小时)：</label>
                                                    <div class="col-sm-1">
                                                        <input type="text" name="duration" id="duration" number="true" value="24" aria-required="false" class="form-control" placeholder="请输入时长">
                                                    </div>
                                                </div>
                                                <div class="form-group" style="display:none">
                                                    <label class="col-sm-2 control-label">活动日期：</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="start_time" id="start_time" value="@ViewBag.NowTime " placeholder="开始日期" required="" aria-required="true" class="form-control pull-right ">
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                    <label style="float:left;"> - </label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="end_time" id="end_time" placeholder="结束日期" class="form-control pull-right">
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                </div>
                                            }
                                            else if (Model.TypeId == 2 || Model.TypeId == 4)
                                            {
                                                <input type="hidden" id="service_rate" name="service_rate" value="0" />
                                                <input type="hidden" name="red_packet" id="red_packet" value="0">
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">人数：</label>
                                                    <div class="col-sm-1">
                                                        <input type="text" name="require_num" id="require_num" number="true" value="3" aria-required="false" class="form-control" placeholder="请输入人数">
                                                    </div>
                                                    <label class="col-sm-2 control-label">时长(小时)：</label>
                                                    <div class="col-sm-1">
                                                        <input type="text" name="duration" id="duration" number="true" value="24" aria-required="false" class="form-control" placeholder="请输入时长">
                                                    </div>
                                                </div>
                                                <div class="form-group" style="display:none">
                                                    <label class="col-sm-2 control-label">活动日期：</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="start_time" id="start_time" value="@ViewBag.NowTime " placeholder="开始日期" required="" aria-required="true" class="form-control pull-right ">
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                    <label style="float:left;"> - </label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="end_time" id="end_time" placeholder="结束日期" class="form-control pull-right">
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                </div>
                                            }
                                            else
                                            {
                                                @*<div class="form-group">
                <label class="col-sm-2 control-label">服务费率(％)：</label>
                <div class="col-sm-1">
                    <input type="text" name="service_rate" id="service_rate" digits="true" class="form-control" placeholder="请输入服务费率" required="" value="0" aria-required="true" number="true">
                    <span class="help-block m-b-none"></span>
                </div>
            </div>*@
                                                <input type="hidden" id="service_rate" name="service_rate" value="0" />
                                                <input type="hidden" name="red_packet" id="red_packet" value="0">
                                                <input type="hidden" id="require_num" name="require_num" value="0" />
                                                <input type="hidden" name="duration" id="duration" value="0">
                                                <input type="hidden" id="start_time" name="start_time" value="@ViewBag.NowTime" />
                                            }
                                            <div class="form-group" style="display:none">
                                                <label class="col-sm-3 control-label">备注：</label>
                                                <div class="col-sm-9">
                                                    <textarea name="remark" id="remark" maxlength="500" class="form-control" placeholder="请输入备注" rows="3"></textarea>
                                                    <span class="help-block m-b-none"></span>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>
                                            <div class="form-group">
                                                <div class="col-sm-4 col-sm-offset-2">
                                                    <button class="btn btn-primary" onclick="btnAddGoods()" id="btnSave" type="button">提交，下一步</button>
                                                </div>
                                            </div>
                                        </div>

                                    }
                                    else
                                    {
                                        <div style="text-align:center;padding-bottom:100px;font-weight:bolder;">店铺参数错误，请重试！</div>
                                    }
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

</div>

@section JS{
    <script src="~/Content/js/jquery.form.js"></script>
    <script src="~/Content/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/Content/plugins/validate/messages_zh.min.js"></script>
    <script src="~/Content/js/UploadImg/js/webuploader.js"></script>
    <script src="~/Content/js/UploadImg/js/jquery.sortable.js"></script>
    <script>
        var s_id=@Model.ShopId;
    </script>
    <script src="~/Content/js/UploadImg/js/goodsUpload.js"></script>
    <script src="~/Content/js/UploadImg/js/goodsContentUpload.js"></script>
    <script>
        var addService = [];
        $(function(){
            get_service_list();//商品服务
            get_freight_template(0,"#freight_template","");
            $('#start_time').datepicker({
                autoclose: true
            });

            $('#end_time').datepicker({
                autoclose: true
            });
           $("#is_new").change(function() {
              var obj=$(this);
              if(obj.is(':checked')){obj.val("true");}
              else{obj.val("false");}
            });
           $("#is_top").change(function() {
              var obj=$(this);
              if(obj.is(':checked')){obj.val("true");}
              else{obj.val("false");}
           });
           layui.use('upload', function(){
               var $ = layui.jquery
               ,upload = layui.upload;
               //多图片上传
               upload.render({
                   elem: '#test2'
                 ,url: domain + "/tools/UploadPCImage?type=goods"
                 ,multiple: true
                 ,size:1024
                 ,before: function(obj){
                     //预读本地文件示例，不支持ie8
                     obj.preview(function(index, file, result){
                         console.log(index);
                         $('#demo2').append('<img title="'+ file.name +'" style="width=120px;height:120px;" src="'+ result +'" class="layui-upload-img">')
                     });
                 }
                 ,done: function(file,res){
                     console.log(file);
                     console.log(res);
                     $('#demo3').append('<img alt="'+ file.name +'" style="width=120px;height:120px;" src="'+ res.info +'" class="layui-upload-img">')

                     //上传完毕
                 }
               });
           });
        });
    </script>
    <script src="~/Content/js/goods.js"></script>
}


